<template>
<Modal v-model="modalEdit" fullscreen @on-cancel="handleModalEditCancel" 
@on-ok="handleModalEditOK" ok-text="提交">
	<template #header>
		<Icon custom="iconfont icon-Word"/>&nbsp;告知审批表&nbsp;
	</template>
	<div><Row justify="center"><Col span="16">
		<Form ref="baseform"  :label-width="150">
		<Card title="案件情况" icon="ios-bookmark">
			<template #extra>
				{{baseform.party_name}}&nbsp;涉嫌&nbsp;{{baseform.cause_name}}
			</template>
			<FormItem label="违法事实及证据">
				<Input v-model="baseform.facts" maxlength="300" show-word-limit type="textarea" :rows="5"/>
			</FormItem>
			<FormItem label="当事人意见">
				<Input v-model="baseform.party_opinion" maxlength="300" show-word-limit type="textarea" :rows="5"/>
			</FormItem>
			<Alert show-icon>
				处罚（拆除）依据
				<template #desc>{{baseform.regulation}} </template>
			</Alert>
			<template v-for="(element,p) in baseform.penaltys">
				<Alert show-icon>
					{{'罚则'+(p+1)}}
					<template #desc>{{element.penalty_detail}}</template>
				</Alert>
				<div style="padding: 32px;">
					<div v-for="(item) in baseform.penaltys[p].items">
						<Row><Col :span="1">
							<input type="radio" :name="p" :id="item.item_id"
							:value="item.item_id" v-model="baseform.penaltys[p].item"/>
						</Col><Col :span="23">
							<label :for="item.item_id">{{item.item_text}}</label>
						<br><br></Col></Row>
					</div>
				</div>
			</template>
		</Card>
		<br>
		<Card title="承办人处理意见及理由" icon="ios-bookmark">
			<template #extra>
				提交日期：<DatePicker v-model="baseform.date1" type="date" placeholder="选择日期" style="width: 200px"></DatePicker>
			</template>
			<Input v-model="baseform.undertaker_opinion" maxlength="300" show-word-limit type="textarea" :rows="3"/>
		</Card>
		</Form>
	</Col></Row></div>
</Modal>
</template>

<script>
import {dateUtils,appendDoc} from '@/libs/tools.js'
import config from '@/config'
export default{
	data(){
		return {
			modalEdit:true,
			baseform:{}
		}
	},
	methods:{
		handleModalEditCancel(){
			this.$router.go(-1)
		},
		handleModalEditOK(){
			let data={...this.baseform}
			data.cause_items=[]
			for (let i = 0; i < data.penaltys.length; i++) {
				data.cause_items.push(data.penaltys[i].item)
			}
			data.cause_item=data.cause_items.join()
			dateUtils.formatDates(data,"date1")
			data.undertaker_name=this.$store.state.user.userInfo.uid
			data.docs=appendDoc(data.docs,"doc152")
			this.$axios.post('mainCase1CreateDoc152.action',data).then(res=>{
				window.open(config.baseUrl+res.data,'_blank')
				this.$router.go(-1)
			})
			
		}
	},
	mounted(){
		this.$axios.post('mainCase1GetDoc152.action',{
			case_no:this.$route.query.case_no,
			party_type:this.$route.query.party_type
		}).then(res=>{
			this.baseform={...this.baseform,...res.data}
			dateUtils.dateNotNull(this.baseform,"date1")
			if(this.baseform.cause_item!=null){
				let a=this.baseform.cause_item.split(',')
				this.baseform.penaltys.forEach((e,i)=>{
					e.item=a[i]
				})
			}
		})
	}
}
</script>

<style>
</style>